Enumerating large (20-digit) [probable] prime numbers

Posted by Paul Baker on Stack Overflow See other posts from Stack Overflow or by Paul Baker
Published on 2010-04-04T13:43:10Z Indexed on 2010/04/04 13:53 UTC
Read the original article Hit count: 190

Filed under:
|

Given A, on the order of 10^20, I'd like to quickly obtain a list of the first few prime numbers greater than A. OK, my needs aren't quite that exact - it's alright if occasionally a composite number ends up on the list.

What's the fastest way to enumerate the (probable) primes greater than A?

Is there a quicker way than stepping through all of the integers greater than A (other than obvious multiples of say, 2 and 3) and performing a primality test for each of them? If not, and the only method is to test each integer, what primality test should I be using?

© Stack Overflow or respective owner

Related posts about primes

Related posts about algorithm